package cz.schovjan.proj.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import cz.schovjan.proj.dao.IConcertDao;
import cz.schovjan.proj.entity.ConcertEntity;

/**
 * Implementace IConcertDao.
 * @author schovjan
 *
 */
@Repository
public class JpaConcertDao implements IConcertDao {

	private static final String FIND_ALL = "select c from ConcertEntity as c";
	
	@PersistenceContext
	private EntityManager em;
	
	
	@Override
	public void add(ConcertEntity ce) {
		em.persist(ce);
	}

	
	@Override
	public ConcertEntity find(Integer idC) {
		return em.find(ConcertEntity.class, idC);
	}


	@SuppressWarnings("unchecked")
	@Override
	public List<ConcertEntity> findAll() {
		return em.createQuery(FIND_ALL).getResultList();
	}

}
